function getAllCitys(){
	//得到所有地市
    $.ajax({
        async:false,
   		url : '/area/getAllCitys',
		type : "post",
		dataType : "json",
		success : function(ret) {
			if (ret.state == 'ok') {
				$('#city').html("<option value=''>请选择</option>");
				$('#county').html("<option value=''>请选择</option>");
				$('#town').html("<option value=''>请选择</option>");
				$('#village').html("<option value=''>请选择</option>");
				var aaa=ret.data;
				for(i in aaa){
					$("#city").append('<option value="'+aaa[i].id+'">'+aaa[i].areaName+'</option>');
				}
			} else {
				layer.msg(ret.msg, {icon: 2, offset: '10px'});
			}
		},
		error: function() {
      } 
  });
}
function searchCounty(){
	if($('#city').val()==""){
		$('#county').html("<option value=''>请选择</option>");
		$('#town').html("<option value=''>请选择</option>");
		$('#village').html("<option value=''>请选择</option>");
	}else{
		$.ajax({
				async:false,
			  	url : '/area/searchNextArea',
				type : "post",
				data : {areaId:$('#city').val()},
				dataType : "json",
				success : function(ret) {
					$('#county').html("<option value=''>请选择</option>");
					$('#town').html("<option value=''>请选择</option>");
					$('#village').html("<option value=''>请选择</option>");
					for(var i=0;i<ret.data.length;i++){
						$('#county').append("<option value='"+ret.data[i].id+"' >"+ret.data[i].areaName+"</option>");
					}
				},
				error: function() {
		         // console.log(0);
		      } 
		  });
	}
}
function searchTown(){
	if($('#county').val()==""){
		$('#town').html("<option value=''>请选择</option>");
		$('#village').html("<option value=''>请选择</option>");
	}else{
		$.ajax({
				async:false,
			  	url : '/area/searchNextArea',
				type : "post",
				data : {areaId:$('#county').val()},
				dataType : "json",
				success : function(ret) {
					$('#town').html("<option value=''>请选择</option>");
					$('#village').html("<option value=''>请选择</option>");
					for(var i=0;i<ret.data.length;i++){
						$('#town').append("<option value='"+ret.data[i].id+"' >"+ret.data[i].areaName+"</option>");
					}
				},
				error: function() {
		         // console.log(0);
		      } 
		  });
	}
}
function searchVillage(){
	if($('#town').val()==""){
		$('#village').html("<option value=''>请选择</option>");
	}else{
		$.ajax({
				async:false,
			  	url : '/area/searchNextArea',
				type : "post",
				data : {areaId:$('#town').val()},
				dataType : "json",
				success : function(ret) {
					$('#village').html("<option value=''>请选择</option>");
					for(var i=0;i<ret.data.length;i++){
						$('#village').append("<option value='"+ret.data[i].id+"' >"+ret.data[i].areaName+"</option>");
					}
				},
				error: function() {
		         // console.log(0);
		      } 
		  });
	}
}